package com.gmail.mariska.martin.service;

import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

import com.google.common.util.concurrent.AbstractScheduledService;

public class ConsoleWriterService extends AbstractScheduledService {
	static final Logger logger = Logger.getLogger(ConsoleWriterService.class);

	@Override
	protected void runOneIteration() throws Exception {
		logger.warn("Console warning at " + new Date().getTime() + " with state " + this.state());
	}

	@Override
	protected Scheduler scheduler() {
		return Scheduler.newFixedDelaySchedule(0, 500, TimeUnit.MILLISECONDS);
	}

	@Override
	protected void startUp() throws Exception {
		logger.warn("Console writer startsUp : " + this.state());
	}

	@Override
	protected void shutDown() throws Exception {
		logger.warn("Console writer shuttingDown : " + this.state());
	}

}
